package coms.mianshi.proxy.staticproxy;

/**
 * @program: item_02
 * @description: 静态代理
 * @author: LL
 * @create: 2021-03-02 13:57
 */

//静态代理对象实现IUserDao接口
public class UserDapProxy implements IUserDao {

    private IUserDao target;

    public UserDapProxy(final IUserDao target) {
        this.target = target;
    }

    @Override
    public void save() {
        System.out.println("开启事务");
        this.target.save();
        System.out.println("提交事务");
    }

    public static void main(final String[] args) {
        //目标对象
        final IUserDao userDao = new UserDao();
        //代理对象
        final UserDapProxy userDapProxy = new UserDapProxy(userDao);
        userDapProxy.save();

    }
}
